@using BlazorApp.Pages.Common.Html
@using BlazorApp.Pages.Common.Html.HTable
@using BlazorApp.Pages.Common.Metadata
@using BlazorApp.Pages.Event
@using k8s.Models
@using Mapster
@inherits BlazorApp.Pages.Common.DrawerPageBase<k8s.Models.V1RoleBinding>
@if (RoleBinding != null)
{
    <RoleBindingAction Item="RoleBinding" MenuMode="MenuMode.Horizontal"></RoleBindingAction>
    <Divider Orientation="left" Style="font-weight:bold">@L["Metadata"]</Divider>
    <MetadataView Item="RoleBinding.Metadata" ExplainFieldPrefix="roleBinding"></MetadataView>
    <Divider Orientation="left" Style="font-weight:bold">@L["Spec"]</Divider>
    <HTable Bordered Column="1">

        @if (RoleBinding.RoleRef is not null)
        {
            <HTableColumn Title=@L["Role"] ExplainField="roleBinding.roleRef">
                <RefView Ref="@(RoleBinding.RoleRef.Adapt<V1ObjectReference>())" FullView="true"></RefView>
            </HTableColumn>
        }
        @if (RoleBinding.Subjects is { Count: > 0 })
        {
            <HTableColumn Title=@L["Subjects"] ExplainField="roleBinding.subjects">
                @foreach (var subject in RoleBinding.Subjects)
                {
                    <RefView Ref="@(subject.Adapt<V1ObjectReference>())" FullView="true"></RefView>
                }
            </HTableColumn>
        }
    </HTable>
    <MiniEventListView Uid="@RoleBinding.Metadata.Uid"></MiniEventListView>
}
